﻿using DotNetCore.CAP;
using EIP.Common.Message.Email.Dto;
using EIP.Common.Message.Sms.Dto;
using EIP.Common.Message.WebSite.Dto;

namespace EIP.Common.Message
{
    /// <summary>
    /// 消息管理
    /// </summary>
    public interface IMessageManagerLogic
    {
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="input"></param>
        void SendSms(SendSmsInput input);

        /// <summary>
        /// 发送站内消息
        /// </summary>
        /// <param name="input"></param>
        void SendWebSite(SendWebSiteInput input);

        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="input"></param>
        void SendEmail(SendEmailInput input);

        /// <summary>
        /// 发送微信公众号信息
        /// </summary>
        /// <param name="input"></param>
        void SendOffiAccount(SendOffiAccountInput input);

        /// <summary>
        /// 发送App
        /// </summary>
        /// <param name="input"></param>
        void SendApp(SendAppInput input);
    }
    /// <summary>
    /// 消息管理逻辑实现
    /// </summary>
    public class MessageManagerLogic : IMessageManagerLogic
    {
        /// <summary>
        /// 
        /// </summary>
        private readonly ICapPublisher _publisher;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="publisher"></param>
        public MessageManagerLogic(ICapPublisher publisher)
        {
            _publisher = publisher;
        }

        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="input"></param>
        public void SendEmail(SendEmailInput input)
        {
            _publisher.Publish("EIP.Message.Send.Email", input);
        }

        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="input"></param>
        public void SendSms(SendSmsInput input)
        {
            _publisher.Publish("EIP.Message.Send.Sms", input);
        }

        /// <summary>
        /// 发送站内信息
        /// </summary>
        /// <param name="input"></param>
        public void SendWebSite(SendWebSiteInput input)
        {
            _publisher.Publish("EIP.Message.Send.WebSite", input);
        }

        /// <summary>
        /// 发送微信公众号信息
        /// </summary>
        /// <param name="input"></param>
        public void SendOffiAccount(SendOffiAccountInput input)
        {
            _publisher.Publish("EIP.Message.Send.OffiAccount", input);
        }

        /// <summary>
        /// 发送App
        /// </summary>
        /// <param name="input"></param>
        public void SendApp(SendAppInput input)
        {
            _publisher.Publish("EIP.Message.Send.App", input);
        }
    }
}